import numpy as np


# 1.创建1维数组
arr1 = np.array([1, 2, 3, 4])
print(arr1)
print(arr1.shape)
print(arr1.size)
print(arr1.ndim)

# 2.创建二维数组
arr2 = np.array([[1, 2], [3, 4], [5, 6]])
print(arr2)
print(arr2.shape)
print(arr2.size)
print(arr2.ndim)

arr3 = np.arange(10)
print(arr3)
print("------------")
# 3.
arr4 = np.zeros((3, 3), dtype=np.int32)
print(arr4)

arr5 = np.ones((3, 3), dtype=np.int32)
print(arr5)
print("-----------------------")
# 4.创建主对角线为1，其余元素为0的方阵
arr6 = np.identity(5, dtype=np.int64)
print(arr6)
print("-----------------------")
# 5.创建主对角线为1，其余元素为0的矩阵
arr7 = np.eye(4, 5, dtype=np.int32)
print(arr7)

# 6.矩阵的运算
data1 = np.array([10, 20, 30, 40])
data2 = np.arange(4)
print(data1 - data2)
